</schema>
<enum id="org.gnome.shell.geoclue.AccuracyLevel">
- <value value="0" nick="off"/>
<value value="1" nick="country"/>
<value value="4" nick="city"/>
<value value="5" nick="neighborhood"/>
<schema id="org.gnome.shell.location"
path="/org/gnome/shell/location/"
gettext-domain="@GETTEXT_PACKAGE@">
+ <key type="b" name="enabled">
+ <default>true</default>
+ <_summary>Geolocation services are enabled.</_summary>
+ <_description>
+ If true, applications are allowed to access location information.
+ </_description>
+ </key>
<key name="max-accuracy-level" enum="org.gnome.shell.geoclue.AccuracyLevel">
<default>'exact'</default>
<_summary>The maximum accuracy level of location.</_summary>
<_description>
Configures the maximum level of location accuracy applications are
- allowed to see. Valid options are 'off' (disable location tracking),
- 'country', 'city', 'neighborhood', 'street', and 'exact' (typically
- requires GPS receiver). Please keep in mind that this only controls
- what GeoClue will allow applications to see and they can find user's
- location on their own using network resources (albeit with street-level
- accuracy at best).
+ allowed to see. Valid options are 'country', 'city', 'neighborhood',
+ 'street', and 'exact' (typically requires GPS receiver). Please keep in
+ mind that this only controls what GeoClue will allow applications to see
+ and they can find user's location on their own using network resources
+ (albeit with street-level accuracy at best).
</_description>
</key>
</schema>
const LOCATION_SCHEMA = 'org.gnome.shell.location';
const MAX_ACCURACY_LEVEL = 'max-accuracy-level';
+const ENABLED = 'enabled';
var GeoclueIface = '<node> \
<interface name="org.freedesktop.GeoClue2.Manager"> \
this.parent();
this._settings = new Gio.Settings({ schema_id: LOCATION_SCHEMA });
+ this._settings.connect('changed::' + ENABLED,
+ Lang.bind(this, this._onMaxAccuracyLevelChanged));
this._settings.connect('changed::' + MAX_ACCURACY_LEVEL,
Lang.bind(this, this._onMaxAccuracyLevelChanged));
this._propertiesChangedId = this._proxy.connect('g-properties-changed',
Lang.bind(this, this._onGeocluePropsChanged));
- this._availableAccuracyLevel = this._proxy.AvailableAccuracyLevel;
this._syncIndicator();
this._proxy.AddAgentRemote('gnome-shell', Lang.bind(this, this._onAgentRegistered));
},
_onOnOffAction: function() {
- if (this._getMaxAccuracyLevel() == 0)
- this._settings.set_enum(MAX_ACCURACY_LEVEL, this._availableAccuracyLevel);
- else
- this._settings.set_enum(MAX_ACCURACY_LEVEL, 0);
+ let enabled = this._settings.get_boolean(ENABLED);
+ this._settings.set_boolean(ENABLED, !enabled);
},
_onSessionUpdated: function() {
},
_updateMenuLabels: function() {
- if (this._getMaxAccuracyLevel() == 0) {
- this._item.status.text = _("Disabled");
- this._onOffAction.label.text = _("Enable");
- } else {
+ if (this._settings.get_boolean(ENABLED)) {
this._item.status.text = this._indicator.visible ? _("In Use") : _("Enabled");
this._onOffAction.label.text = _("Disable");
+ } else {
+ this._item.status.text = _("Disabled");
+ this._onOffAction.label.text = _("Enable");
}
},
},
_getMaxAccuracyLevel: function() {
- return this._settings.get_enum(MAX_ACCURACY_LEVEL);
+ if (this._settings.get_boolean(ENABLED))
+ return this._settings.get_enum(MAX_ACCURACY_LEVEL);
+ else
+ return 0;
},
_notifyMaxAccuracyLevel: function() {
let unpacked = properties.deep_unpack();
if ("InUse" in unpacked)
this._syncIndicator();
- if ("AvailableAccuracyLevel" in unpacked) {
- this._availableAccuracyLevel = this._proxy.AvailableAccuracyLevel;
-
- if (this._getMaxAccuracyLevel() != 0)
- this._settings.set_enum(MAX_ACCURACY_LEVEL, this._availableAccuracyLevel);
- }
}
});